<span page-title ng-model="contentView">{{ 'Available Content Views for Composite Content View:' | translate }} {{ contentView.name }}</span>

<h3 translate>
  Add Content Views to {{ contentView.name }}
</h3>

<div data-extend-template="layouts/partials/table.html">
  <div data-block="messages">
    <p bst-alert="info" ng-show="contentView.components.length === 0">
      <span translate>
        In order to add a content view to a composite view you must first publish an initial version of the content view.
      </span>
    </p>
  </div>

  <div data-block="list-actions">
    <button type="button" class="btn btn-primary"
            ng-disabled="table.numSelected === 0"
            ng-click="addContentViews()">
      <span translate>Add Content Views</span>
    </button>
  </div>

  <span data-block="no-rows-message" translate>
    No Content Views available to add to {{ contentView.name }}.  Create some non-composite Content Views first.
  </span>

  <span data-block="no-search-results-message" translate>
    No Content Views match the search.
  </span>

  <div data-block="table">
    <table class="table table-bordered table-striped">
      <thead>
        <tr bst-table-head row-select>
          <th bst-table-column translate>Name</th>
          <th bst-table-column translate>Version</th>
          <th bst-table-column translate>Environment</th>
          <th bst-table-column translate>Description</th>
          <th bst-table-column translate>Content</th>
        </tr>
      </thead>

      <tbody>
      <tr bst-table-row
          ng-repeat="componentContentView in table.rows"
          row-select="componentContentView" ng-init="componentContentView.versionId='latest'">
        <td bst-table-cell>{{ componentContentView.name }}</td>
        <td bst-table-cell ng-init="availableVersions = getAvailableVersions(componentContentView)">
          <select class="form-control"
                  name="componentContentView.version"
                  ng-if="componentContentView.versions.length > 0"
                  ng-model="componentContentView.versionId"
                  ng-selected="latest"
                  ng-options="cvv.id as cvv.version for cvv in availableVersions | orderBy: '-id'">
          </select>
          <span ng-if="componentContentView.versions.length === 0" ng-model="componentContentView.version" translate>Always Use Latest (Currently no versions)</span>
        </td>
        <td bst-table-cell>
          <span ng-show="componentContentView.environments.length !== 0"
                ng-repeat="environment in componentContentView.environments">
            {{ environment.name }}<span ng-if="!$last">, </span>
          </span>
          <span ng-show="componentContentView.environments.length === 0" translate>
            Not yet published
          </span>
        </td>
        <td bst-table-cell>{{ componentContentView.description }}</td>
        <td bst-table-cell>
          <div>
            <a ui-sref="content-view.repositories.yum.list({contentViewId: componentContentView.id})" translate>
              {{ componentContentView.repositories.length || 0 }} Repositories
            </a>
          </div>
        </td>
      </tr>
      </tbody>
    </table>
  </div>
</div>

